#ifndef PROTOSRVMANAGER_H
#define PROTOSRVMANAGER_H

#include <memory>
#include <map>
#include <typeinfo>
#include <string>
#include <QtGlobal>
#include <QString>
#include <ace/Log_Msg.h>

#include "protocol.h"

class ProtoSrvManager
{
public:
    static std::auto_ptr<ProtoSrvManager>& getInstance();

    void        registerProtoSrv(ProtoSrv* srv);
    ProtoSrv*   getProtoSrv(qint32 proType);

    bool        encode(ACE_OutputCDR &cdr,ProtoSrv* srv);
    ProtoSrv*   decode(ACE_SOCK_Stream &stream);

    ~ProtoSrvManager();
protected:
    ProtoSrvManager();
    ProtoSrvManager(const ProtoSrvManager &);
    ProtoSrvManager &operator=(const ProtoSrvManager &);

private:
    friend class std::auto_ptr<ProtoSrvManager>;
    friend class std::auto_ptr<ProtoSrv>;

    std::map<std::string,ProtoSrv*>             _srv_map;
    static std::auto_ptr<ProtoSrvManager>       _mgr;
};

#endif // PROTOSRVMANAGER_H
